<template>
	<view>
		<view class="header">
			<view class="navbar">
				<view class="navbar-fixed">
					<!-- 状态栏小程序撑起高度 -->
					<view :style="{height:statusBarHeight+'px'}"></view>
					<view class="navbar-content" :style="{height:navBarHeight+'px',width:windowWidth+'px'}">
						<!-- <image src="../../static/image/back.png" @click="back()"></image> -->
						<view class="navbar-search">分类</view>
					</view>
				</view>
				<!-- 需要添加占位符高度  状态栏高度+导航栏高度（否则下面tab会塌陷）indexOf-->
				<view :style="{height: statusBarHeight+navBarHeight+'px'}"></view>
			</view>
			<view class="searchbox" @click="togoodslist()">
				<view class="search">
					<view class="scan">
						<image src="../../static/ss1.png"></image>
					</view>
					<view class="inputbox">
						<input placeholder="搜索" />
					</view>
					<view class="searchbut">搜索</view>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="leftbox">
				<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
					@scrolltolower="lower" @scroll="scroll">
					<view class="scroll-view-item" v-for="(item,index) in leftlist" :key="index" 
					@click="handleone(index)" :style="{'background':index==currone?'#FFF':''}">
						<view v-if="index==currone" class="tit"></view>
						<view>{{item}}</view>
					</view>
				</scroll-view>
			</view>
			<view class="rightbox">
				<view class="secondary">
					<view class="somebox">
						<view class="sometip" v-for="(item,index) in tiplist" :key="index" @click="handletwo(index)"
						:style="{'background':index!==currtwo?'#F7F7F7':'','color':index==currtwo?'#FF6229':''}">
							{{item}}
						</view>
					</view>
					<view class="yin"></view>
					<view class="opensecondary">
						<image src="../../static/xia.png"></image>
					</view>
				</view>
				<view class="threelevel">
					<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-g" @scrolltoupper="upper"
						@scrolltolower="lower" @scroll="scroll">
						<view class="listbox" v-for="(item,index) in 8" :key="index">
							<view class="imgbox">
								<image src="../../static/logo.png"></image>
							</view>
							<view class="infobox">
								<view class="namebox">俏娃宝贝儿童尤克里里</view>
								<view class="catebox">小吉他 | 玩具</view>
								<view class="salenum">已销100</view>
								<view class="numbox">
									<view class="price">￥29.00</view>
									<view class="num">
										<image src="../../static/add.png"></image>
										<view class="number">1</view>
										<image src="../../static/jian.png"></image>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
					
				</view>
			</view>
			<view style="height: 120rpx;"></view>
			<view class="navbut">
				<view class="leftbox">
					<image src="../../static/car.png"></image>
					<view class="numbox">
						<view>合计</view>
						<view>￥58.00</view>
					</view>
				</view>
				<view class="rightbox">
					<view>去结算</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 20,
				/* 状态栏高度 */
				navBarHeight: 45,
				/* 导航栏高度 */
				windowWidth: 375,
				/* 窗口宽度 */
				/* 设定状态栏默认高度 */
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				leftlist:['玩具乐器','男鞋女鞋','箱包服饰','个护美妆','乳饮酒水'],//一级分类列表
				currone:"",//一级分类索引
				tiplist:['全部','早教启智','敲打玩具'],//二级分类列表
				currtwo:'',//二级分类索引
			}
		},
		onShow() {
			this.getnav()
		},
		methods: {
			getnav() {
				// 获取手机系统信息
				const info = uni.getSystemInfoSync()
				// 设置状态栏高度（H5顶部无状态栏小程序有状态栏需要撑起高度）
				this.statusBarHeight = info.statusBarHeight
				this.windowWidth = info.windowWidth
				// 除了h5 app mp-alipay的情况下执行
				// #ifndef H5 || APP-PLUS || MP-ALIPAY
				// 获取胶囊的位置
				const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
				console.log(menuButtonInfo);
				// (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度
				this.navBarHeight = (menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - info
					.statusBarHeight)
				this.windowWidth = menuButtonInfo.left
				// #endif
			},
			togoodslist() {
				uni.navigateTo({
					url: '/pages/goodslist/goodslist'
				})
			},
			scroll: function(e) {
				this.old.scrollTop = e.detail.scrollTop
			},
			upper: function(e) {
				// console.log(e)
			},
			lower: function(e) {
				// console.log(e)
			},
			//一级分类
			handleone(index){
				this.currone = index
			},
			//二级分类
			handletwo(index){
				this.currtwo = index
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F7F7;
		overflow: hidden;
	}
</style>
<style lang="scss" scoped>
	.header {
		height: 22vh;
		// background: url(https://zdcloud.zxkjnc.com/images/6165.png) no-repeat;
		background: linear-gradient(180deg, #F94D29 0%, #F7F7F7 100%);
		width: 100%;
		// background-size: 100% 300rpx;
	}

	.navbar {
		.navbar-fixed {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 399;
			width: 100%;
			// height: 102rpx;
			// padding-bottom: 20rpx;
			background: transparent;


			.navbar-content {
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 0rpx 30rpx;
				// height: 142rpx;
				box-sizing: border-box;

				image {
					width: 19rpx;
					height: 35rpx;
					margin-right: 20rpx;
				}

				.navbar-search {
					display: flex;
					align-items: center;
					// padding: 0 10px;
					width: 100%;
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FFF;

				}

			}
		}
	}

	.searchbox {
		width: 100%;
		height: 134rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		// margin-top: 40rpx;

		.search {
			width: 690rpx;
			height: 40rpx;
			padding: 15rpx 0;
			background: #FFFFFF;
			border-radius: 36rpx;
			// border: 2rpx solid #F94D29;
			display: flex;
			align-items: center;
			margin: 0 auto;

			.scan {
				width: 76rpx;
				text-align: center;
				border-right: solid 2rpx #F2F2F2;

				image {
					width: 32rpx;
					height: 28rpx;
				}
			}

			.inputbox {
				width: 448rpx;
				height: 40rpx;
				padding: 0 24rpx;

				>input {
					width: 100%;
				}
			}

			.searchbut {
				width: 112rpx;
				height: 62rpx;
				background: linear-gradient(180deg, #F94D29 0%, #F99529 100%);
				border-radius: 36rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #F7F7F7;
				line-height: 62rpx;
				text-align: center;
			}
		}
	}

	.box {
		height: 78vh;
		display: flex;
		background-color: #FFF;
		width: 100%;
		.leftbox {
			width: 172rpx;
			background-color: #F7F7F7;
			.scroll-Y {
				height: 68vh;
				
				.scroll-view-item {
					height: 84rpx;
					line-height: 84rpx;
					text-align: center;
					font-size: 28rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #222222;
					position: relative;
					.tit{
						position: absolute;
						left: 0;
						width: 6rpx;
						top: 10rpx;
						height: 64rpx;
						background: linear-gradient(270deg, #F94D29 0%, #F99529 100%);
						border-radius: 20rpx ;
					}
				}
			}
		}
		.rightbox{
			width: 578rpx;
			height: 78vh;
			.secondary{
				width: 578rpx;
				height: 84rpx;
				background-color: #F7F7F7;
				display: flex;
				border-bottom: 2rpx solid #F5F5F5;
				.somebox{
					display: flex;
					align-items: center;
					width: 502rpx;
					background-color: #FFF;
					.sometip{
						height: 50rpx;
						background: linear-gradient(90deg, #FFE9E1 0%, #FFF8F5 100%);
						border-radius: 8rpx;
						width: fit-content;
						padding: 0 18rpx;
						line-height: 50rpx;
						margin: 0 8rpx;
						font-size: 28rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #222222;
					}
				}
				.yin{
					width: 14rpx;
					height: 84rpx;
					background: linear-gradient(270deg, #E8E8E8 0%, rgba(232,232,232,0) 100%);
					opacity: 1;
				}
				.opensecondary{
					width: 72rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					image{
						width: 27rpx;
						height: 15rpx;
					}
				}
			}
			.threelevel{
				width: 578rpx;
				height: 62vh;
				background-color: #FFF;
				.scroll-g{
					height: 62vh;
					.listbox{
						display:flex;
						align-items:center;
						.imgbox{
							width: 220rpx;
							text-align: center;
							image{
								width: 180rpx;
								height: 180rpx;
							}
						}
						.infobox{
							width: 330rpx;
							.namebox{
								font-size: 30rpx;
								font-family: Source Han Sans CN-Medium, Source Han Sans CN;
								font-weight: 500;
								color: #000000;
							}
							.catebox{
								font-size: 24rpx;
								font-family: Source Han Sans CN-Regular, Source Han Sans CN;
								font-weight: 400;
								color: #AC7E27;
							}
							.salenum{
								font-size: 20rpx;
								font-family: Source Han Sans CN-Regular, Source Han Sans CN;
								font-weight: 400;
								color: #888888;
							}
							.numbox{
								display: flex;
								align-items: center;
								justify-content: space-between;
								.price{
									font-size: 30rpx;
									font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
									font-weight: normal;
									color: #FE5326;
								}
								.num{
									display: flex;
									align-items: center;
									image{
										width: 40rpx;
										height: 40rpx;
									}
									.number{
										width: 50rpx;
										text-align: center;
									}
								}
							}
						}
					}
				}
			}
		}
		.navbut{
			width: 750rpx;
			height: 120rpx;
			background: #FFFFFF;
			border-radius: 48rpx;
			opacity: 1;
			position: fixed;
			bottom: 0;
			z-index: 199;
			display: flex;
			align-items: center;
			justify-content: center;
			.leftbox{
				width: 480rpx;
				height: 96rpx;
				border-radius: 48rpx 0rpx 0rpx 48rpx;
				background-color: #1C1C1C;
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
				font-weight: normal;
				color: #FFFFFF;
				image{
					width: 44rpx;
					height: 42rpx;
					margin: 0 30rpx;
				}
			}
			.rightbox{
				width: 210rpx;
				height: 96rpx;
				background: linear-gradient(180deg, #F94D29 0%, #F99529 100%);
				border-radius: 0rpx 48rpx 48rpx 0rpx;
				font-size: 30rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				text-align: center;
				line-height: 96rpx;
			}
		}
	}
</style>
